Repository navigation
feat: connect to a linked environment from its read-only thread - #39439
Open
juliusmarminge wants to merge 3 commits into
Open
juliusmarminge wants to merge 3 commits into
juliusmarminge wants to merge 3 commits into
Conversation
juliusmarminge
force-pushed
the
t3code/links/connect-to-interact
branch
from
November 20, 2026 00:10
22502d9 to
4bdb4ec
Compare
Contributor
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosNo All 64 scenario measurements
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
juliusmarminge
force-pushed
the
t3code/links/connect-to-interact
branch
2 times, most recently
from
November 20, 2026 03:23
3c7d79f to
22ba699
Compare
This was referenced Nov 20, 2026
juliusmarminge
force-pushed
the
t3code/links/connect-to-interact
branch
2 times, most recently
from
November 20, 2026 06:34
eac3dc2 to
79192bf
Compare
… linked environment Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
juliusmarminge
force-pushed
the
t3code/links/connect-to-interact
branch
from
November 20, 2026 07:07
79192bf to
091cf25
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #39406.
Problem
#39406 lets a client connected to environment A read a thread that lives on a linked environment B, but only read it. To reply, approve or stop the thread, the user had to leave the read-only view, find B's address, create a pairing code on B and add B by hand.
What this does
The read-only view gets one action, Connect to interact. It is the primary action of the bar that stands where a composer would (the read-only bar #39406 shares with subagent threads). Since #39406 was reworked the linked view is the thread's own stream drawn by the standard timeline, so on web the bar is
LinkedThreadPane'sReadOnlyComposerBarbelowReadOnlyThreadTimelinein thelinked-threadright panel tab (and below the loading or error state before the first snapshot), and on mobile it is the bar under the sheet's read-only list. What comes of it shows as a notice on that same bar: "Connecting to fs-17…" while pairing, the unreachable message, and on web a "needs a pairing code" notice with Enter code that reopens the pre-filled dialog. Nothing is in the view's header.full-access. The client asks A (peerLinks.pairClient). A asks B over its link for a one-time pairing credential for that client and returns it with the addresses it reaches B at. The client checks which address answers it as B, pairs there exactly as it does from a pairing link, saves B as an environment and opens the same thread. No code is shown or typed. On web the thread opens in the main view, the way any thread on a connected environment does and the way the existing resolver opens this one from now on, and its read-only tab closes; on mobile the sheet closes and the thread opens.If no address of B answers the client, the bar says "fs-17 is not reachable from this device" and the view stays read-only. If the client is already connected to B the read-only view never opens (the existing resolver sends it to the thread there), so the action is not offered.
How B exposes it
A dedicated HTTP route,
POST /api/peer-link/client-pairing, authenticated by the link's own session.Link sessions were
/mcp-only. The alternative was a guarded MCP tool hidden from tool listings. I chose the route because a tool is reachable by anything that can call/mcp, which includes every thread credential an agent holds, and hiding a tool from listings is only discovery. The route never consults the thread-credential registry, so no agent on B, link-started or not, can authenticate to it, and nothing appears in any model's tool list. No model-facing tool text changed.Security rules and where each is enforced
PeerClientPairingIssuer.issue: the caller must be a peer-link session whose access isfull-access, and an administrator's runtime-mode ceiling below full access also refuses. A skips the round trip for a lower link, but B does not rely on that.access:write(CLIENT_GUARDED_RPC_SCOPES). It is not an MCP tool on either side. B's route refuses any caller that is not a full-access peer-link session: other MCP clients get 403; thread credentials, ordinary client sessions and no credential get 401; a browserOrigingets 403.AuthStandardClientScopes. The credential is one-time and lasts 3 minutes. Its label is<client> · via <A>, so B's Sharing & access shows where it came from, and it is revoked there like any other.no-store, and A drops the cause of an unreadable response instead of logging it. Nothing is written to a thread or persisted event.linkClientPairing; A answers a typedunsupported/versionwithout calling a B that lacks it.Rationale kept in a code comment and in
docs/internals/environment-auth.md: a full-access link's agents already run as B's user and could runt3 auth pairing createthemselves, so minting here adds no power. Any lower link would gain some.Scope
Maintainer feature work, requested by Julius as a follow-up to the Linked environments beta that shipped in #16653–#17130. It is not an outside contribution.
Tested
Server, A and B as real layers in one process on a
TestClock(apps/server/src/peer/PeerClientPairing.test.ts):Phone · via Laptop, redeemable once, carrying only the client's scopes on A (and none outside a normal pairing); an unredeemed one is dead after 3 minutesread-only,approval-requiredandautolinks →unsupportedfrom A without contacting B, and 403 from B when A is bypassed with the link's own tokendisabledunsupported/version, and B is never askedRpcAuthorization.test.ts: a client withoutaccess:writeon A is refused before the handler runs.Client (
packages/client-runtime/src/linkedThread.test.ts): one step vs fallback, which address is used, and the unreachable case spending nothing.Rebased onto the reworked #39406 (the linked thread is now the standard thread stream). The server side is unchanged. The client action and notices moved into the new view components with no change in behaviour; nothing of the deleted paged transcript is left in this PR. Rerun after the rebase:
vp run check:changed,vp run i18n:check, the six server test files this touches (85 tests), andAddEnvironmentDialog.browser.test.tsx.Surfaces
Not included: after the manual fallback succeeds the user opens the thread again themselves (its link now resolves to B directly); the one-step path opens it for them.
Web, run for real between two dev servers named nucbox and fs-17, with nucbox holding a full-access link to fs-17 over its tailnet address. The browser was paired with nucbox only.
These screenshots are out of date. They show the paged transcript that #39406 no longer has; the body above the bar is now the standard timeline. The bar, its action and the result are the same.
No pairing code was shown or typed. On fs-17 the new client is listed as
Chrome on Linux · via cups(the link was made from a shell outside the renamed test host, hence "cups"). Mobile has not been run on a device.Latest real run
Run for real after the rebase onto the single-stream base: clicking "Connect to interact" in the bottom bar paired the browser with fs-17 with no code shown and opened the thread there in the main view.
Claude Fable 5.2, Claude Code in T3 Code
🤖 Generated with Claude Code